<?php

namespace App\Http\Controllers\Baidu;

use Illuminate\Http\Request;
use	Exception;

include_once ('../app/libary/Baidu/sms_service_CreativeService.php');

use sms_service_CreativeService;
use GetCreativeRequest;
use App\Http\Controllers\Baidu\AdgroupController;


class CreativeController
{

    var $creative;
    var $getCreativeRequest;
    var $adgroup;
    public function __construct()
    {
        $this->creative = new sms_service_CreativeService();
        $this->getCreativeRequest = new GetCreativeRequest();
        $this->adgroup = new AdgroupController();
    }


    /**
     * @return mixed|string|void
     *
     *获取创意信息
     */
    public function getCreative()
    {
        $data = $this->adgroup->getAdgroupData();

        $ids = [];
//        $ids = [2602964561];//  单元ID需要传值
        $ids = [2602965557];//  单元ID需要传值

        $creativeFields = ['creativeId','adgroupId','title','pause','status','description1',
            'description2','pcDestinationUrl','pcDisplayUrl','mobileDestinationUrl',
            'mobileDisplayUrl','devicePreference','tabs'];

        $idType = 5;

        $this->getCreativeRequest->setCreativeFields($creativeFields);
        $this->getCreativeRequest->addId($ids);
        $this->getCreativeRequest->setIdType($idType);

        $result = $this->creative->getCreative($this->getCreativeRequest);

        return json_encode($result);


    }
    
    
    
}